/**
 * Copyright (c) 2016-2019, Michael Yang 杨福海 (fuhai999@gmail.com).
 * <p>
 * Licensed under the GNU Lesser General Public License (LGPL) ,Version 3.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.gnu.org/licenses/lgpl-3.0.txt
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.jpress.module.advert.controller;

import com.jfinal.kit.Ret;
import com.jfinal.plugin.activerecord.Page;
import io.jboot.Jboot;
import io.jboot.utils.StrUtils;
import io.jboot.web.controller.annotation.RequestMapping;
import io.jboot.web.controller.validate.EmptyValidate;
import io.jboot.web.controller.validate.Form;
import io.jpress.JPressConsts;
import io.jpress.commons.layer.SortKit;
import io.jpress.core.menu.annotation.AdminMenu;
import io.jpress.core.template.TemplateManager;
import io.jpress.model.Menu;
import io.jpress.model.User;
import io.jpress.service.MenuService;
import io.jpress.web.base.AdminControllerBase;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import javax.inject.Inject;
import java.util.List;
import java.util.Set;

/**
 * @author Michael Yang 杨福海 （fuhai999@gmail.com）
 * @version V1.0
 * @Package io.jpress.module.advert.admin
 */
@RequestMapping("/admin/advert")
public class _AdvertController extends AdminControllerBase {

//    @Inject
//    private ArticleService articleService;
//    @Inject
//    private ArticleCategoryService categoryService;
//    @Inject
//    private ArticleCommentService commentService;

    @AdminMenu(text = "数据分析", groupId = "advert")
    public void index() {

//        String status = getPara("status");
//        String title = getPara("title");
//        Long categoryId = getParaToLong("categoryId");
//
//        Page<Article> page =
//                StringUtils.isBlank(status)
//                        ? articleService._paginateWithoutTrash(getPagePara(), 10, title, categoryId)
//                        : articleService._paginateByStatus(getPagePara(), 10, title, categoryId, status);
//
//        setAttr("page", page);
//
//        int draftCount = articleService.findCountByStatus(Article.STATUS_DRAFT);
//        int trashCount = articleService.findCountByStatus(Article.STATUS_TRASH);
//        int normalCount = articleService.findCountByStatus(Article.STATUS_NORMAL);
//        setAttr("draftCount", draftCount);
//        setAttr("trashCount", trashCount);
//        setAttr("normalCount", normalCount);
//        setAttr("totalCount", draftCount + trashCount + normalCount);
//
//
//        List<ArticleCategory> categories = categoryService.findListByType(ArticleCategory.TYPE_CATEGORY);
//        SortKit.toLayer(categories);
//        setAttr("categories", categories);
//
//        flagCheck(categories, categoryId);

        render("advert/article_list.html");
    }


    @AdminMenu(text = "配置", groupId = "advert")
    public void write() {

//        List<ArticleCategory> categories = categoryService.findListByType(ArticleCategory.TYPE_CATEGORY);
//        SortKit.toLayer(categories);
//        setAttr("categories", categories);
//
//
//        int articleId = getParaToInt(0, 0);
//
//        Article advert = null;
//        if (articleId > 0) {
//            advert = articleService.findById(articleId);
//            if (advert == null) {
//                renderError(404);
//                return;
//            }
//            setAttr("advert", advert);
//
//            List<ArticleCategory> tags = categoryService.findListByArticleId(articleId, ArticleCategory.TYPE_TAG);
//            setAttr("tags", tags);
//
//            Long[] categoryIds = categoryService.findCategoryIdsByArticleId(articleId);
//            flagCheck(categories, categoryIds);
//        }
//
//        String editMode = advert == null ? getCookie(JPressConsts.COOKIE_EDIT_MODE) : advert.getEditMode();
//        setAttr("editMode", JPressConsts.EDIT_MODE_MARKDOWN.equals(editMode)
//                ? JPressConsts.EDIT_MODE_MARKDOWN
//                : JPressConsts.EDIT_MODE_HTML);
//
//        initStylesAttr("article_");



        render("advert/setting.html");
    }













}
